package o;

import android.app.Activity;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.huawei.appmarket.R;
import java.lang.ref.WeakReference;

public class exx {
    private Activity ˊ;
    private ext ˎ;
    private cxx ˏ;
    private String ॱ;

    static class e implements Runnable {
        private WeakReference<Activity> ˊ;
        private ext ˋ;
        private cks ˎ;
        private String ˏ;

        private e(ext o_ext, String str, Activity activity, cks o_cks) {
            this.ˋ = o_ext;
            this.ˏ = str;
            this.ˊ = new WeakReference(activity);
            this.ˎ = o_cks;
        }

        public void run() {
            fhz ˋ = fho.ˏ().ˋ("ShortcutBundle");
            if (ˋ == null) {
                if (this.ˎ != null) {
                    this.ˎ.enableNetworking();
                }
            } else if (this.ˊ == null || this.ˊ.get() == null) {
                if (this.ˎ != null) {
                    this.ˎ.enableNetworking();
                }
                Logger.ˎ("CheckShortcutRunnable", "activity == null");
            } else {
                Activity activity = (Activity) this.ˊ.get();
                cxu o_cxu = (cxu) ˋ.ॱ(cxu.class);
                o_cxu.ˋ(new exy(activity, new d(this) {
                    final /* synthetic */ e ˋ;

                    {
                        this.ˋ = r1;
                    }

                    public void ˊ(@NonNull ext o_ext, int i) {
                        if (i == 4) {
                            Toast.makeText(ContentManager.getInstant().getContext(), this.ˋ.ˏ, 0).show();
                        }
                        if (this.ˋ.ˎ != null) {
                            this.ˋ.ˎ.enableNetworking();
                        }
                    }
                }));
                o_cxu.ˎ(activity, this.ˋ, null, true);
            }
        }
    }

    public exx(Activity activity, ext o_ext, String str, cxx o_cxx) {
        this.ˊ = activity;
        this.ˎ = o_ext;
        this.ॱ = str;
        this.ˏ = o_cxx;
    }

    public void ˎ(Activity activity, final cks o_cks, final Class<?> cls) {
        View inflate = LayoutInflater.from(activity).inflate(R.layout.exit_center_dialog, null);
        ((TextView) inflate.findViewById(R.id.delete_warn)).setText(activity.getString(R.string.exit_delete_warn, new Object[]{activity.getString(R.string.exit_confirm), this.ˎ.ॱ()}));
        View findViewById = inflate.findViewById(R.id.center_dialog_layout);
        int ˎ = ewb.ˎ(activity);
        findViewById.setPaddingRelative(ˎ, ˎ, ˎ, findViewById.getPaddingBottom());
        cku ˋ = cku.ˋ(null, null);
        ˋ.ॱ(-2, activity.getString(R.string.shortcut_exit));
        ˋ.ˊ(inflate);
        final String str = exv.ˏ(activity) + this.ˎ.ˊ();
        ˋ.ॱ(new cks(this) {
            final /* synthetic */ exx ˏ;

            public void enableNetworking() {
                exv.ॱ(str);
                this.ˏ.ॱ(cls, o_cks);
            }

            public void upgrade() {
                exv.ॱ(str);
                if (o_cks != null) {
                    o_cks.upgrade();
                }
            }

            public void ˋ() {
            }
        });
        ˋ.ˎ(activity);
    }

    private void ॱ(Class<?> cls, cks o_cks) {
        if (this.ˎ == null) {
            Logger.ˎ("DeleteShortcutHelper", "can not remove shortcut,centerAppInfo == null");
            return;
        }
        if (this.ˏ != null) {
            this.ˎ.ˎ(this.ˏ.ˏ());
        }
        cxx ˋ = exw.ˋ(this.ˊ, this.ˎ, cls);
        fhz ˋ2 = fho.ˏ().ˋ("ShortcutManager");
        if (ˋ2 == null) {
            if (o_cks != null) {
                o_cks.enableNetworking();
            }
        } else if (((cyf) ˋ2.ॱ(cyf.class)).ˊ(this.ˊ, ˋ)) {
            try {
                new Handler().postDelayed(new e(this.ˎ, this.ॱ, this.ˊ, o_cks), 100);
            } catch (Exception e) {
                Logger.e("DeleteShortcutHelper", "check shortcut error," + e.toString());
            }
        } else {
            Toast.makeText(ContentManager.getInstant().getContext(), this.ॱ, 0).show();
            if (o_cks != null) {
                o_cks.enableNetworking();
            }
        }
    }
}
